# /bin/bash
if [ ! -d '/usr/local/src' ]; then
	mkdir -r /usr/local/src
fi
cd /usr/local/src && wget https://nginx.org/download/nginx-1.22.0.tar.gz

tar -xvhf nginx-1.22.0.tar.gz
cd nginx-1.22.0
if [ ! rpm -qa |grep yum >> /dev/null ]; then
	echo '未找到yum，请先安装yum'
	exit 1
fi
yum -y install gcc pcre-devel zlib zlib-devel

./configure --prefix=/usr/local/nginx --with-http_ssl_module
make && make install

echo -e '# nginx\nPATH=$PATH:/usr/local/nginx/sbin/' >> /etc/profile && . /etc/profile && nginx

if [ ! -f '/usr/bin/curl' ]; then
	echo 'warn:未找到curl'
fi
echo '安装完成，请使用命令curl http://0.0.0.0:80检查是否正常输出'
